/*************************************************************************
	> File Name: P1238.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2024-12-25 09:43:17
 ************************************************************************/
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define MAX_N 15

int grid[MAX_N + 5][MAX_N + 5];
int m, n, s_x, s_y, e_x, e_y;
bool visit[MAX_N + 5][MAX_N + 5];
vector<string> ans;
int dir[4][2] = {
    {0, -1}, {-1, 0}, {0, 1}, {1, 0}
};
int cnt = 0;

void dfs(int x, int y) {
    if (x < 1 || x > m || y < 1 || y > n) return ;
    if (grid[x][y] == 0 || visit[x][y]) return ;
    string temp;
    temp += '(';
    temp += to_string(x);
    temp += ",";
    temp += to_string(y);
    temp += ")";
    if (x == e_x && y == e_y) {
        cnt = 1;
        for (int i = 0; i < ans.size(); i++) {
            cout << ans[i] << "->";
        }
        cout << temp << endl;
        return ;
    }
    visit[x][y] = 1;
    ans.push_back(temp);
    for (int k = 0; k < 4; k++) {
        int dx = x + dir[k][0];
        int dy = y + dir[k][1];
        dfs(dx, dy);
    }
    ans.pop_back();
    visit[x][y] = 0;
    return ;
}

int main() {
    cin >> m >> n;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> grid[i][j];
        }
    }
    cin >> s_x >> s_y >> e_x >> e_y;
    dfs(s_x, s_y);
    if (cnt == 0) cout << -1 << endl;
    return 0;
}
